<?php

    include '..\Models.php';

    DbConnector::Connect();
    
    $result = Place::GetPlaces();
    
    DbConnector::Disconnect();

?>

<html>
    <body>
    
    <table>
        <tr>
            <td>Name</td>
            <td>Description</td>
            <td>Lat</td>
            <td>Lon</td>
            <td>Tag</td>
            <td></td>
            <td></td>
        </tr>
                
        <?
        for ($i=0; $i < count($result); $i++){            
        ?>
        
        <tr>
            <td><?= $result[$i]->name; ?></td>
            <td><?= $result[$i]->description; ?></td>
            <td><?= $result[$i]->lat; ?></td>
            <td><?= $result[$i]->lon;?></td>
            <td><?= $result[$i]->tag; ?></td>
            <td><a href="SubmitPlace.php?id=<?= $result[$i]->id; ?>">Edit</a></td>
            <td><a href="SubmitPlace.php?delete=<?= $result[$i]->id; ?>">Delete</a></td>
        </tr>
        
        <?        
        }    
        ?>
    </table>
    
    <a href="SubmitPlace.php">Add New Place</a>
    
    </body>
</html>